import styles from './SysModule.less';
import { Component } from 'react';
import { connect } from 'dva';

import demon from '../../assets/imags/module/Demon_icon.png';
import drug from '../../assets/imags/module/drug_icon.png';
import crm from '../../assets/imags/module/crm_icon.png';
import web from '../../assets/imags/module/web_icon.png';
import data from '../../assets/imags/module/data_icon.png';
import erp from '../../assets/imags/module/erp_icon.png';
import app from '../../assets/imags/module/app_icon.png';

import { Link } from 'react-router-dom';

import { Row, Col, Form } from 'antd';

@Form.create()
export default class SysModule extends Component {
  module(image, title, sysurl, isDirect = false) {
    if (isDirect) {
      return (
        <a href={sysurl}>
          <Row type="flex" justify="space-around" align="middle" className={styles.innerContainer}>
            <img alt="系统模块" src={image} className={styles.imageStyle} />
          </Row>
          <Row type="flex" justify="space-around" align="middle" className={styles.btnTitle}>
            {title}
          </Row>
        </a>
      );
    } else {
      console.log('----title: ' + title + '---url:' + sysurl);
      return (
        <div>
          <Link to={sysurl}>
            <Row
              type="flex"
              justify="space-around"
              align="middle"
              className={styles.innerContainer}
            >
              <img alt="系统模块" src={image} className={styles.imageStyle} />
            </Row>
            <Row type="flex" justify="space-around" align="middle" className={styles.btnTitle}>
              {title}
            </Row>
          </Link>
        </div>
      );
    }
  }

  render() {
    return (
      <div className={styles.container}>
        <Row type="flex" justify="space-around" align="middle">
          <Col>{this.module(demon, '演示中心', '')}</Col>
          <Col>
            <Row type="flex" justify="space-around" align="middle">
              {this.module(drug, '智能药房', '')}
            </Row>
            <Row type="flex" justify="space-around" align="middle">
              {this.module(crm, '邻康CRM', '')}
            </Row>
          </Col>
          <Col>{this.module(web, '官方网站', 'http://www.lk199.cn', true)}</Col>
          <Col>
            <Row type="flex" justify="space-around" align="middle">
              {this.module(data, '数据中心', '/data/alldata')}
            </Row>
            <Row type="flex" justify="space-around" align="middle">
              {this.module(erp, '邻康ERP', '')}
            </Row>
          </Col>
          <Col>{this.module(app, 'APP&机器人', '')}</Col>
        </Row>
      </div>
    );
  }
}
